package edu.cmu.cs.stage3.alice.core.property;

import java.io.IOException;

import edu.cmu.cs.stage3.alice.core.Element;
import edu.cmu.cs.stage3.alice.core.ReferenceGenerator;
import edu.cmu.cs.stage3.alice.core.applet.AppletXmlStruct;
import edu.cmu.cs.stage3.io.DirectoryTreeStorer;

public class StringProperty extends ObjectProperty {

 public StringProperty (Element owner, String name, String defaultValue) {
  super( owner, name, defaultValue, String.class );
  }

 public String getStringValue () {
  return (String)getValue();
  }

 //Rem @Override
 protected void decodeObject (org.w3c.dom.Element node, java.util.Vector referencesToBeResolved) throws java.io.IOException {
  set( getNodeText( node ) );
  }

 //Rem @Override
 protected void encodeObject (org.w3c.dom.Document document, org.w3c.dom.Element node, DirectoryTreeStorer storer, edu.cmu.cs.stage3.alice.core.ReferenceGenerator referenceGenerator) throws java.io.IOException {
  node.appendChild( createNodeForString( document, getStringValue() ) );
  }

 //Rem @Override
 protected AppletXmlStruct encodeObjectToXml (ReferenceGenerator referenceGenerator) throws IOException {
  AppletXmlStruct struct = new AppletXmlStruct();
  struct.addElement(getStringValue());
  return struct;
  }

 }
